<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>修改密码</title>
	<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
	<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
	<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
	<style>
		body{
			background: #f3f3f3;
		}
		.container{
			margin: 64px auto auto auto;
			width: 400px;
		}
		.title{
			text-align: center;
		}
		.login{
			margin-top: 64px;
		}
		.btn_group{
			text-align: center;
		}
		.return_result{
			padding: 8px;
			text-align: center;
		}
	</style>
	</head>
	<body>
		<div class="container">
			<h1 class="title">修改密码</h1>
			<div class="login">
				<div class="panel panel-default">
					<div class="panel-body">
						<div class="form-group" id="input1">
							<label class="control-label" for="inputError1" id="inputError1"></label>
							<input type="text" class="form-control" id="emailInput" placeholder="邮箱">
						</div>
						<div class="form-group" id="input2">
							<label class="control-label" for="inputError2" id="inputError2"></label>
							<input type="text" class="form-control" id="return_vcode" placeholder="邮箱收到的验证码">
							
						</div>
						<div class="form-group" id="input3">
							<label class="control-label" for="inputError3" id="inputError3"></label>
							<input type="password" class="form-control" id="pswInput" placeholder="新密码">
							
						</div>
						<div class="form-group" id="input4">
							<label class="control-label" for="inputError4" id="inputError4"></label>
							<input type="text" class="form-control" id="psw_again" placeholder="重新输入新密码">
							
						</div>
		
						<div class="btn_group">
							<div>
								<a href="javascript:;">
									<img src="captcha.do" id="captcha">
								</a>
								<br><br>
							</div>
							<button type="button" class="btn btn-primary" id="regBtn">确定修改</button>
						</div>
						<div class="return_result"></div>
					</div>
				</div>
			</div>
		</div>
		<script>
			$(".regBtn").click(function(){
				var email = $("#emailInput").val();
				var vcode = $("#return_vcode").val();
				var new_pass = $("#pswInput").val();
				var new_pass_again = $("#psw_again").val();
				$.post('forgetChangePassword.do',{
					email:email,
					vcode:vcode,
					new_pass:new_pass,
					new_pass_again:new_pass_again
				},function(data){
					try{
						var result = JSON.parse(data);
						if(result == 0)
						{
							$(".return_result").html("修改密码成功，请返回到登录界面。");
						}
						else if(result == 103)
						{
							$(".return_result").html("两次密码输入不系统，请重新输入。");
						}
						else if(result == 112){
							$(".return_result").html("输入密码位数要大于6位。");
						}
						else if(result == 106){
							$(".return_result").html("key不正确。");
						}
						else if(result == 107){
							$(".return_result").html("key过期。");
						}
						else if(result == 101){
							$(".return_result").html("用户不存在。");
						}
						else{
							$(".return_result").html("系统异常。");
						}
					}catch(e){
						//TODO handle the exception
					}
				});
			})
		</script>
	</body>
</html>
